<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="text" v-my-directive>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        //全局自定义指令
        /* Vue.directive("my-directive", {
            inserted(el) {
                el.style.border = "10px solid red"
            }
        }) */
        let vm = new Vue({
            el: '#app',
            data: {},
            directives: { //局部自定义指令
                "my-directive": {
                    inserted(el) {
                        el.style.border = "10px solid red";
                        el.focus();
                    }
                }
            },
            methods: {}
        });
    </script>
</body>

</html>